package com.rms.hkpc.presenter;

import com.google.gson.reflect.TypeToken;
import com.rms.hkpc.apiresult.ApiResultData;
import com.rms.hkpc.apiresult.PagedList;
import com.rms.hkpc.db.dto.WorksOrderDto;
import com.rms.hkpc.db.query.BaseQuery;
import com.rms.hkpc.model.listener.OnResultListener;
import com.rms.hkpc.model.WorksOrderModel;
import com.rms.hkpc.view.IWorksOrderView;

public class WorksOrderPresenter extends BasePresenter<IWorksOrderView> {
    private WorksOrderModel model = new WorksOrderModel();
    public void getData(BaseQuery query) {
        model.getData(query, new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onGetDataSuccess((ApiResultData<PagedList<WorksOrderDto>>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onGetDataFails(e);
                }
            }
        }, new TypeToken<ApiResultData<PagedList<WorksOrderDto>>>() {
        }.getType());
    }
}
